<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2024/3/21
 * Time: 17:49
 */

namespace plugin\admin\app\model\user;


use app\common\lib\Common;
use plugin\admin\app\model\Base;

class UserModel extends Base
{
    protected $table = 'video_user';

    protected $primaryKey = 'userid';

    protected $headimgurl = 'https://ai-video-1320718644.cos.ap-guangzhou.myqcloud.com/video/test/image/20240401/png/78c8502563218baccd80.png';

    protected static $instance;

    public $timestamps = false;

    public static function getInstance()
    {
        //        if(is_object(self::$instance)){
//            return self::$instance;
//        }

        return new self();
    }

    public function getUserAgentVip($userSn,$dateTime=null)
    {
        $dateTime==false && $dateTime = date('Y-m-d');

        $agentLevel = false;
        //        $where = ['user_sn'=>$userSn,['effect_time','<=',$dateTime],['expire_time','>=',$dateTime],['status','>',0]];
        //        $agentLevel = UserLevelChangeModel::getInstance()->getWhere($where)->orderBy('createtime','desc')->value('change_after_level');
        if($agentLevel==false){
            $agentLevel = $this->getWhere(['user_sn'=>$userSn])->value('agent_level');
        }

        return $agentLevel?:1;
    }
}